
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>DataType.Number.parse()</title>

<style type="text/css">
/*margin and padding on body element
  can introduce errors in determining
  element position and are not recommended;
  we turn them off as a foundation for YUI
  CSS treatments. */
body {
	margin:0;
	padding:0;
}
</style>

<link type="text/css" rel="stylesheet" href="../../build/cssfonts/fonts-min.css" />
<script type="text/javascript" src="../../build/yui/yui-min.js"></script>


<!--begin custom header content for this example-->
<style type="text/css">
/* custom styles for this example */
#demo label {display:block;}
#demo fieldset {margin:1em;}
</style>

<!--end custom header content for this example-->

</head>

<body class="yui3-skin-sam  yui-skin-sam">

<h1>DataType.Number.parse()</h1>

<div class="exampleIntro">
	The Number module of the DataType Utility allows you to take a data value and convert it to a number.
			
</div>

<!--BEGIN SOURCE CODE FOR EXAMPLE =============================== -->

<form id="demo">
    <fieldset>
        <label for="demo_input">Value to parse: <input type="text" id="demo_input"></label>
    </fieldset>
    <fieldset>
        <input type="submit" id="demo_btn" value="Alert parsed number">
    </fieldset>
</form>



<script type="text/javascript">
YUI().use("node", "datatype-number", function (Y) {
    Y.on("submit", function(e){
        e.halt();
        
        var input = Y.one("#demo_input").get("value"),
            output = Y.DataType.Number.parse(input);
                
        if(output === "") {
            output += "(Invalid value)"
        }
        alert(output);
    }, "#demo");
});
</script>

<!--END SOURCE CODE FOR EXAMPLE =============================== -->

</body>
</html>
